package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-23 16:56
 * @Modified By:
 */
public class FindMaxAverage_643 {
    public static void main(String[] args){
        int[] nums = new int[]{3};
        System.out.println(findMaxAverage(nums,1));
    }

    public static double findMaxAverage(int[] nums,int k){
        double result = Integer.MIN_VALUE;

        for (int i = 0; i <= nums.length - k; i++) {
            double sum = 0;
            for (int j = i + k - 1; j >= i; j--) {
                sum += nums[j];
            }
            if (result < (sum / k)){
                result = sum / k;
            }
        }

        return result;
    }
}
